package com.qupai.controller.user;

import com.qupai.constant.StatusConstant;
import com.qupai.entity.Prizes;
import com.qupai.result.Result;
import com.qupai.service.PrizesService;
import com.qupai.vo.PrizesVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController("userPrizesController")
@RequestMapping("/user/prizes")
@Slf4j
@Tag(name = "志愿-C端-奖品浏览接口")
public class PrizesController {
    @Resource
    private PrizesService prizesService;

    @GetMapping("/list")
    @Operation(summary = "根据学院分类id查询奖品")
    public Result<List<PrizesVO>> list(Long collegesId){
        Prizes prizes=new Prizes();
        prizes.setCollegesId(collegesId);
        prizes.setStatus(StatusConstant.ENABLE);

        List<PrizesVO> prizesVOList=prizesService.selectPrizesList(prizes);
        return Result.success(prizesVOList);
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据id查询奖品")
    public Result<PrizesVO>getById (@PathVariable Long id){
        log.info("根据id查询奖品:{}",id);
        PrizesVO prizesVO=prizesService.getById(id);
        return Result.success(prizesVO);
    }

}
